home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / anote / setup.exe / {app} / Server Documents / sendpasswordtoemail.php < prev    next >
Encoding:
PHP Script  |  2004-09-27  |  1.8 KB  |  61 lines

  1. <?php
  2. // Send an email with the password to the user
  3.  
  4. // Variable init
  5.     include ("init.php");
  6.  
  7. // Connect to the database    
  8.     include ("connect.php");
  9.  
  10. function get_string($h, $s, $e)
  11. {
  12. // Check that the start tag is NOT the same as the end tag
  13.     if ($s == $e)
  14.        return "";
  15.  
  16. // Check that the start tag exists
  17.     if (strpos ($h, $s, 0) === false)
  18.        return "";
  19.  
  20. // Check that the end tag exists
  21.     if (strpos ($h, $e, 0) === false)
  22.        return "";
  23.  
  24.     $sp = strpos($h, $s, 0) + strlen($s);  
  25.     $ep = strpos($h, $e, 0); 
  26.  
  27. // Check that the start tag comes before the end tag
  28.     if ($sp >= $ep)
  29.        return "";
  30.  
  31.     return substr($h, $sp, $ep-$sp);
  32. }
  33.  
  34. // Get the xml
  35.     $data = $HTTP_RAW_POST_DATA;
  36.  
  37. // Find the user information
  38.     $start = '<SendEmail>';
  39.     $end = '</SendEmail>';
  40.     $found = get_string($data, $start, $end);
  41.  
  42. // Get the data
  43.     $username        = get_string ($data, "<username>", "</username>");
  44.     $query="SELECT * FROM users WHERE user='$username'";
  45.     $reply = mysql_query ($query);
  46.     $num_result = mysql_num_rows ($reply);
  47.     if ($num_result != 0)    {
  48.         $password     = base64_decode (mysql_result ($reply, 0, "password"));
  49.         $email         = base64_decode (mysql_result ($reply, 0, "email"));
  50.     }
  51. // Email the password
  52.     $subject = "Password to A Note";
  53.     $body = "This message has been automatically sent from A Note's server.
  54.     You can not reply to this message.\n\nThe user's information is:\nUser name: ".base64_decode ($username) ."\nPassword: " .$password ."\n
  55.     Start A Note and go to Options -> Database and fill in the information there.\n\nIf you have any questions, go to A Note's
  56.     webpage http://sourceforge.net/projects/a-note/\n\n\nThe A Note staff...";
  57.     mail($email, $subject, $body);
  58.  
  59. // Everytning is ok
  60.     echo $xmlstart ."<info info=\"password has been emailed\"/>";
  61. ?>